package org.example.dao;

import org.example.domain.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

public class UserDaoImpl extends SqlSessionDaoSupport implements IUserDao {

    @Override
    public List<User> list() {
        return this.getSqlSession().selectList("org.example.domain.User.listAll");
    }

    @Override
    public User get(String id) {
        return this.getSqlSession().selectOne("org.example.domain.User.get", id);
    }

    @Override
    public int insert(User user) {
        return this.getSqlSession().insert("org.example.domain.User.create", user);
    }

    @Override
    public int update(User user) {
        return this.getSqlSession().update("org.example.domain.User.update", user);
    }

    @Override
    public int deleteById(String id) {
        return this.getSqlSession().delete("org.example.domain.User.delete", id);
    }
}
